package com.ctv.my.customview.MaiCustomView.CitySelector.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.TextView;

import com.ctv.my.customview.MaiCustomView.CitySelector.bean.City;
import com.ctv.my.customview.R;

import java.util.List;

/**
 * Created by ms on 2017/7/10.
 */

public class GridViewAdapter extends MyBaseAdapter<City, GridView> {

    private List<City> hotCityList;
    private LayoutInflater inflater;

    public GridViewAdapter(Context ct, List<City> list, GridView view) {
        super(ct, list, view);
        this.hotCityList = list;
        this.inflater = LayoutInflater.from(ct);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.city_select_hot_city_item, null);
            holder.tevHotCity = (TextView) convertView.findViewById(R.id.tev_hot_city);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        String city = hotCityList.get(position).getName();
        holder.tevHotCity.setText(city);
        return convertView;
    }

    class ViewHolder {
        TextView tevHotCity;
    }
}
